home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
dev
/
misc
/
cweb_2_8.lha
/
amiga
/
cweave.ch
< prev
next >
Wrap
Text File
|
1993-01-22
|
8KB
|
297 lines
% If the user specifies "-i" formal parameter declarations won't be indented.
% Therefore we have to set |indent_param_decl| to |TRUE|.
@x
argc=ac; argv=av;
program=weave;
make_xrefs=force_lines=1; /* controlled by command-line options */
common_init();
@y
argc=ac; argv=av;
program=weave;
indent_param_decl=1; /* indent formal parameter declarations by default */
make_xrefs=force_lines=1; /* controlled by command-line options */
common_init();
@z
% Make 'a' and 'g' command line flags.
@x
@d show_banner flags['b'] /* should the banner line be printed? */
@d show_progress flags['p'] /* should progress reports be printed? */
@d show_happiness flags['h'] /* should lack of errors be announced? */
@y
@d show_banner flags['b'] /* should the banner line be printed? */
@d show_progress flags['p'] /* should progress reports be printed? */
@d show_happiness flags['h'] /* should lack of errors be announced? */
@d use_amiga_keywords flags['a'] /* should Amiga/SAS C Keywords be used? */
@d use_german_macros flags['g'] /* should the output be german? */
@d indent_param_decl flags['i'] /* should formal parameter declarations be indented? */
@z
% Insert the Amiga specific keywords into the id-table.
@x
id_lookup("NULL",NULL,quoted);
id_lookup("TeX",NULL,custom);
@y
id_lookup("NULL",NULL,quoted);
id_lookup("TeX",NULL,custom);
if (use_amiga_keywords) {
id_lookup("signed",NULL,int_like);
id_lookup("defined",NULL,sizeof_like);
id_lookup("volatile",NULL,int_like);
id_lookup("pragma",NULL,if_like);
id_lookup("__near",NULL,int_like);
id_lookup("__far",NULL,int_like);
id_lookup("__chip",NULL,int_like);
id_lookup("__regargs",NULL,int_like);
id_lookup("__stdargs",NULL,int_like);
id_lookup("__asm",NULL,int_like);
id_lookup("__saveds",NULL,int_like);
id_lookup("__interrupt",NULL,int_like);
id_lookup("__aligned",NULL,int_like);
id_lookup("__inline",NULL,int_like);
id_lookup("__stackext",NULL,int_like);
id_lookup("__d0",NULL,int_like);
id_lookup("__d1",NULL,int_like);
id_lookup("__d2",NULL,int_like);
id_lookup("__d3",NULL,int_like);
id_lookup("__d4",NULL,int_like);
id_lookup("__d5",NULL,int_like);
id_lookup("__d6",NULL,int_like);
id_lookup("__d7",NULL,int_like);
id_lookup("__a0",NULL,int_like);
id_lookup("__a1",NULL,int_like);
id_lookup("__a2",NULL,int_like);
id_lookup("__a3",NULL,int_like);
id_lookup("__a4",NULL,int_like);
id_lookup("__a5",NULL,int_like);
id_lookup("__a6",NULL,int_like);
id_lookup("__a7",NULL,int_like);
id_lookup("__fp0",NULL,int_like);
id_lookup("__fp1",NULL,int_like);
id_lookup("__fp2",NULL,int_like);
id_lookup("__fp3",NULL,int_like);
id_lookup("__fp4",NULL,int_like);
id_lookup("__fp5",NULL,int_like);
id_lookup("__fp6",NULL,int_like);
id_lookup("__fp7",NULL,int_like);
id_lookup("GLOBAL",NULL,int_like);
id_lookup("IMPORT",NULL,int_like);
id_lookup("STATIC",NULL,int_like);
id_lookup("REGISTER",NULL,int_like);
id_lookup("VOID",NULL,int_like);
id_lookup("LONG",NULL,int_like);
id_lookup("ULONG",NULL,int_like);
id_lookup("LONGBITS",NULL,int_like);
id_lookup("WORD",NULL,int_like);
id_lookup("UWORD",NULL,int_like);
id_lookup("WORDBITS",NULL,int_like);
id_lookup("BYTE",NULL,int_like);
id_lookup("UBYTE",NULL,int_like);
id_lookup("BYTEBITS",NULL,int_like);
id_lookup("STRPTR",NULL,int_like);
id_lookup("APTR",NULL,int_like);
id_lookup("CPTR",NULL,int_like);
id_lookup("SHORT",NULL,int_like);
id_lookup("USHORT",NULL,int_like);
id_lookup("FLOAT",NULL,int_like);
id_lookup("DOUBLE",NULL,int_like);
id_lookup("COUNT",NULL,int_like);
id_lookup("UCOUNT",NULL,int_like);
id_lookup("BOOL",NULL,int_like);
id_lookup("TEXT",NULL,int_like);
id_lookup("PLANEPTR",NULL,int_like);
id_lookup("BPTR",NULL,int_like);
id_lookup("BSTR",NULL,int_like);
id_lookup("Tag",NULL,int_like);
id_lookup("RPTR",NULL,int_like);
id_lookup("DisplayInfoHandle",NULL,int_like);
id_lookup("Object",NULL,int_like);
id_lookup("ClassID",NULL,int_like);
id_lookup("Msg",NULL,int_like);
id_lookup("BPTR",NULL,int_like);
id_lookup("Class",NULL,int_like);
id_lookup("CxObj",NULL,int_like);
id_lookup("CxMsg",NULL,int_like);
id_lookup("PFL",NULL,int_like);
id_lookup("IX",NULL,int_like);
}
@z
% If "+g" is specified, use the german cweb macros.
@x
out_ptr=out_buf+1; out_line=1; *out_ptr='c'; tex_printf("\\input cwebma");
@y
if (use_german_macros) {
out_ptr=out_buf+1; out_line=1; *out_ptr='g'; tex_printf("\\input cwebmac");
} else {
out_ptr=out_buf+1; out_line=1; *out_ptr='c'; tex_printf("\\input cwebma");
}
@z
% Cosmetic correction (see below).
% Not included anymore. Default behaviour is the original behaviour.
%@x
%& |exp| \altt|lbrace| |int_like| |decl|
% & |fn_decl| \altt|lbrace| |int_like| |decl|
% \hfill $F=E^*\,|in|\,|in|$ & \malt {\\{main}()$\{$}
% {\\{main}$(\\{ac},\\{av})$ \&{int} \\{ac};} \cr
%@y
%& |exp| \altt|lbrace| |int_like| |decl|
% & |fn_decl| \altt|lbrace| |int_like| |decl|
% \hfill $F=E^*$ & \malt {\\{main}()$\{$}
% {\\{main}$(\\{ac},\\{av})$ \&{int} \\{ac};} \cr
%@z
% Cosmetic correction (see below).
% Not included anymore. Default behaviour is the original behaviour.
%@x
%& |decl_head| \altt|int_like| |lbrace| |decl| & |fn_decl|
% \altt|int_like| |lbrace| |decl| \hfill $F=D\,|in|\,|in|$
% & |long time () {|\cr
%@y
%& |decl_head| \altt|int_like| |lbrace| |decl| & |fn_decl|
% \altt|int_like| |lbrace| |decl| \hfill $F=D$
% & |long time () {|\cr
%@z
% Cosmetic correction (see below).
% Not included anymore. Default behaviour is the original behaviour.
%@x
%& |fn_decl| |stmt| & |function| \hfill $F\,|out|\,|out|\,|force|\,S$
% & \\{main}() {\dots}\cr
%@y
%& |fn_decl| |stmt| & |function| \hfill $F\,|force|\,S$
% & \\{main}() {\dots}\cr
%@z
% Cweave 2.1 (and higher) indents parameters in function declarations.
% I think this looks rather awful. So provide the option "-i" to switch
% this indenting off.
@x
@<Cases for |exp|@>=
if (cat1==lbrace || cat1==int_like || cat1==decl) {
make_underlined(pp); big_app1(pp); big_app(indent); app(indent);
reduce(pp,1,fn_decl,0,1);
}
@y
@<Cases for |exp|@>=
if (cat1==lbrace || cat1==int_like || cat1==decl) {
make_underlined(pp); big_app1(pp);
if (indent_param_decl) {
big_app(indent); app(indent);
}
reduce(pp,1,fn_decl,0,1);
}
@z
% See above.
@x
@ @<Cases for |decl_head|@>=
if (cat1==comma) {
big_app2(pp); big_app(' '); reduce(pp,2,decl_head,-1,22);
}
else if (cat1==unorbinop) {
big_app1(pp); big_app('{'); big_app1(pp+1); big_app('}');
reduce(pp,2,decl_head,-1,23);
}
else if (cat1==exp && cat2!=lpar && cat2!=exp) {
make_underlined(pp+1); squash(pp,2,decl_head,-1,24);
}
else if ((cat1==binop||cat1==colon) && cat2==exp && (cat3==comma || cat3==semi))
squash(pp,3,decl_head,-1,25);
else if (cat1==lbrace || cat1==int_like || cat1==decl) {
big_app1(pp); big_app(indent); app(indent); reduce(pp,1,fn_decl,0,26);
}
@y
@ @<Cases for |decl_head|@>=
if (cat1==comma) {
big_app2(pp); big_app(' '); reduce(pp,2,decl_head,-1,22);
}
else if (cat1==unorbinop) {
big_app1(pp); big_app('{'); big_app1(pp+1); big_app('}');
reduce(pp,2,decl_head,-1,23);
}
else if (cat1==exp && cat2!=lpar && cat2!=exp) {
make_underlined(pp+1); squash(pp,2,decl_head,-1,24);
}
else if ((cat1==binop||cat1==colon) && cat2==exp && (cat3==comma || cat3==semi))
squash(pp,3,decl_head,-1,25);
else if (cat1==lbrace || cat1==int_like || cat1==decl) {
big_app1(pp);
if (indent_param_decl) {
big_app(indent); app(indent);
}
reduce(pp,1,fn_decl,0,26);
}
@z
% See above.
@x
@ @<Cases for |fn_decl|@>=
if (cat1==decl) {
big_app1(pp); big_app(force); big_app1(pp+1); reduce(pp,2,fn_decl,0,36);
}
else if (cat1==stmt) {
big_app1(pp); app(outdent); app(outdent); big_app(force);
big_app1(pp+1); reduce(pp,2,function,-1,37);
}
@y
@ @<Cases for |fn_decl|@>=
if (cat1==decl) {
big_app1(pp); big_app(force); big_app1(pp+1); reduce(pp,2,fn_decl,0,36);
}
else if (cat1==stmt) {
big_app1(pp);
if (indent_param_decl) {
app(outdent); app(outdent);
}
big_app(force);
big_app1(pp+1); reduce(pp,2,function,-1,37);
}
@z
@x
hash_pointer h; /* index into |hash| */
@y
extern hash_pointer h; /* index into |hash| */
@z